package edu.hm.compiler.scanner.dfa.symbol;

public class Char implements ISymbol
{
    private final int symbol;
    private final int column;
    private final int line;

    /**
     * @param symbol
     * @param line
     * @param col
     */
    public Char( int symbol, int line, int col )
    {
        this.symbol = symbol;
        this.line = line;
        this.column = col;
    }

    /**
     * @param symbol
     */
    public Char( int symbol )
    {
        this( symbol, -1, -1 );
    }

    @Override
    public int getLine()
    {
        // TODO Auto-generated method stub
        return this.line;
    }

    @Override
    public int getColumn()
    {
        // TODO Auto-generated method stub
        return this.column;
    }

    @Override
    public int getChar()
    {
        // TODO Auto-generated method stub
        return this.symbol;
    }

    @Override
    public boolean isEOF()
    {
        return this.symbol < 0;
    }

    @Override
    public int hashCode()
    {
        final int prime = 31;
        int result = 1;
        result = prime * result + this.symbol;
        return result;
    }

    @Override
    public boolean equals( Object obj )
    {
        if( this == obj )
            return true;
        if( obj == null )
            return false;
        if( getClass() != obj.getClass() )
            return false;
        Char other = (Char) obj;
        if( this.symbol != other.symbol )
            return false;
        return true;
    }

    @Override
    public String toString()
    {
        return "Symbol [symbol=" + ( this.symbol < 0 ? "eof" : (char) this.symbol ) + ", column=" + this.column
                + ", line=" + this.line
                + "]";
    }
}
